<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <title>冒牌排序</title>
</head>
<body>


<script>

    //冒泡排序

    len = [12,2,8,5,63,35,16,48,96];

    for (var i = 0; i < len.length-1; i++){
        for (var j = 0; j < len.length - 1 - i; j++){
            if(len[j] > len[j+1]){
                var temp = len[j];
                len[j] = len[j+1];
                len[j+1] = temp;
            }
        }
    }
    console.log(len);

    /*var len1 = [2,1,5,8,6,10,48];
     console.log(len1[0]);
     console.log(len1[1]);
     console.log(len1[2]);
     console.log(len1[3]);
     console.log(len1[4]);
     console.log(len1[5]);
     console.log(len1[6]);
     console.log(len1[7]);
     if(len1[0] > len1[0+1]){
     var tap = len1[0];
     len1[0] = len1[0+1];
     len1[0+1] = tap;
     }
     console.log(len1[0]);
     if(len1[1] > len1[1+1]){
     var tap = len1[1];
     len1[1] = len1[1+1];
     len1[1+1] = tap;
     }
     console.log(len1[1]);
     if(len1[2] > len1[2+1]){
     var tap = len1[2];
     len1[2] = len1[2+1];
     len1[2+1] = tap;
     }
     console.log(len1[2]);
     if(len1[3] > len1[3+1]){
     var tap = len1[3];
     len1[3] = len1[3+1];
     len1[3+1] = tap;
     }
     console.log(len1[3]);
     if(len1[4] > len1[4+1]){
     var tap = len1[4];
     len1[4] = len1[4+1];
     len1[4+1] = tap;
     }
     console.log(len1[4]);
     if(len1[5] > len1[5+1]){
     var tap = len1[5];
     len1[5] = len1[5+1];
     len1[5+1] = tap;
     }
     console.log(len1[5]);
     if(len1[6] > len1[6+1]){
     var tap = len1[6];
     len1[6] = len1[6+1];
     len1[6+1] = tap;
     }
     console.log(len1[6]);*/



</script>

</body>
</html>